home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig15_12.jar / Ch15 / Fig15_12 / QUEUE_C.H < prev    next >
C/C++ Source or Header  |  1997-08-26  |  826b  |  34 lines

  1. // Definition of Queue class composed of List object
  2. #ifndef QUEUE_C
  3. #define QUEUE_C
  4.  
  5. #include "list.h"
  6.  
  7. template<class QUEUETYPE>
  8. class Queue {
  9. public:
  10.    // no constructor; List constructor does initialization
  11.    void enqueue( const QUEUETYPE & );
  12.    int dequeue( QUEUETYPE & );
  13.    int isQueueEmpty() const;
  14.    void printQueue() const;
  15. private:
  16.    List<QUEUETYPE> q;
  17. };
  18.  
  19. template<class QUEUETYPE>
  20. void Queue<QUEUETYPE>::enqueue( const QUEUETYPE &value )
  21.    { q.insertAtBack( value ); }
  22.  
  23. template<class QUEUETYPE>
  24. int Queue<QUEUETYPE>::dequeue( QUEUETYPE &value )
  25.    { return q.removeFromFront( value ); }
  26.  
  27. template<class QUEUETYPE>
  28. int Queue<QUEUETYPE>::isQueueEmpty() const { return q.isEmpty(); }
  29.  
  30. template<class QUEUETYPE>
  31. void Queue<QUEUETYPE>::printQueue() const { q.print(); }
  32.  
  33. #endif
  34.